package kuanshu.controller;

import kuanshu.bean.FangWuJiBenXinXi;
import kuanshu.mapper.FangWuJiBenXinXiMapper;
import kuanshu.util.JsonResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
@CrossOrigin("*")
@RestController
@RequestMapping("/fangwujibenxinxi")
public class FangWuJiBenXinXiController {
    @Resource
    private FangWuJiBenXinXiMapper fangWujiBenXinXiMapper;

    @RequestMapping("/fangyuan")
    public JsonResult fangyuan(){
        List<FangWuJiBenXinXi> list = fangWujiBenXinXiMapper.fangyuan();
        JsonResult jsonResult = new JsonResult(true,200,list,"");
        return jsonResult;
    }

    @RequestMapping("/zuixinfangyuan")
    public JsonResult zuixinfangyuan() {
        List<FangWuJiBenXinXi> list = fangWujiBenXinXiMapper.zuixinfangyuan();
        JsonResult jsonResult = new JsonResult(true, 200, list, "");
        return jsonResult;
    }

    @RequestMapping("/zuipianyifangyuan")
    public JsonResult zuipianyifangyuan() {
        List<FangWuJiBenXinXi> list = fangWujiBenXinXiMapper.zuipianyifangyuan();
        JsonResult jsonResult = new JsonResult(true, 200, list, "");
        return jsonResult;
    }

    @RequestMapping("/chakan")
    public JsonResult chakan(String fangyuanbiaoti) {
        List<FangWuJiBenXinXi> list = fangWujiBenXinXiMapper.chakan("%"+fangyuanbiaoti+"%");
        JsonResult jsonResult = new JsonResult(true, 200, list, "");
        return jsonResult;
    }

    @PostMapping("/tianjia")
    public JsonResult add(FangWuJiBenXinXi fangWuJiBenXinXi) {
        fangWujiBenXinXiMapper.add(fangWuJiBenXinXi);
        JsonResult result = new JsonResult(true, 200, "success", "");
        return result;
    }

}

